
package cn.edu.shengda;

interface ShapeArea{
 public abstract   double getArea();
 public abstract   double getPerimeter();
}
class Rectangle implements ShapeArea{
    double width;
    double height;
    public Rectangle(double w,double h){
        width=w;
        height=h;
    }
   
    @Override
    public double getArea() {
       return width*height;
    }

    @Override
    public double getPerimeter() {
        return 2*(width+height);
    }
    @Override
    public String toString(){
        return "长度="+width+",宽度="+height+",矩形面积="+getArea()+",矩形周长="+getPerimeter();
    }
   
}
class Circle implements ShapeArea{
    double radious;
    public Circle(double r){
        radious=r;
    }
    @Override
    public double getArea() {
       return 3.14*radious*radious;
    }
    @Override
    public double getPerimeter() {
        return 2*3.14*radious;
    }
    @Override
    public String toString(){
        return "半径="+radious+",圆面积="+getArea()+",圆周长="+getPerimeter();
    }
}
public class Test {
    public static void main(String[] args){
       Rectangle a = new Rectangle(7,8);
       System.out.println(a.toString());
       Circle b = new Circle(2.0);
        System.out.println(b.toString());
    }
}